#!/usr/bin/env python
# -*- coding: UTF-8 -*-

import shutil
import os


def removeFile(path):
    if os.path.exists(path) and os.path.isfile(path):
        os.remove(path)
    else:
        print("Failed to remove {0}, casuse {0} is not a file".format(path))


def removeDir(path):
    if os.path.exists(path) and os.path.isdir(path):
        shutil.rmtree(path)
    else:
        print("Failed to remove {0}, cause {0} is not a directory".format(path))

# dest can be a file or directory
def copyFile(src, dest):
    if os.path.exists(src) and os.path.isfile(src):
        shutil.copy(src, dest)
    else:
        print("Failed to copy {0} to {1}, casuse {0} is not a file".format(src, dest))

# dest should not exist
def copyDir(src, dest):
    if os.path.exists(src) and os.path.isdir(src):
        # if dest exist, then copy to dest/src
        if os.path.exists(dest):
            dest = os.path.join(dest, os.path.split(src)[1])
        shutil.copytree(src, dest)
    else:
        print("Failed to copy {0} to {1}, casuse {0} is not a directory".format(src, dest))

def move(src, dest):
    shutil.move(src, dest)
